package main

import (
	"fmt"
	"sync"
)

var wg = sync.WaitGroup{}
var lock = sync.Mutex{}

func add1(count *int) {
	defer wg.Done()
	for i := 0; i < 1000; i++ {
		lock.Lock()
		*count += 1
		lock.Unlock()
	}
}
func lock1(count *int) {
	go add1(count)
	go add1(count)
	go add1(count)
}

func main() {
	count := 0
	wg.Add(3)
	lock1(&count)
	wg.Wait()
	fmt.Println(count)
}
